home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / sgwnd10 / frmtest2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-08-09  |  2.7 KB  |  76 lines

  1. VERSION 5.00
  2. Begin VB.Form frmTest23 
  3.    BorderStyle     =   0  'None
  4.    Caption         =   "Implements IsgPaintSink"
  5.    ClientHeight    =   3048
  6.    ClientLeft      =   0
  7.    ClientTop       =   0
  8.    ClientWidth     =   3504
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   3048
  11.    ScaleWidth      =   3504
  12.    ShowInTaskbar   =   0   'False
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.CheckBox chkPaint 
  15.       Caption         =   "Paint on the forms frame (simple)"
  16.       Height          =   192
  17.       Left            =   180
  18.       TabIndex        =   0
  19.       Top             =   300
  20.       Width           =   2952
  21.    End
  22. Attribute VB_Name = "frmTest23"
  23. Attribute VB_GlobalNameSpace = False
  24. Attribute VB_Creatable = False
  25. Attribute VB_PredeclaredId = True
  26. Attribute VB_Exposed = False
  27. Option Explicit
  28. Implements IsgPaintSink
  29. Private Sub chkPaint_Click()
  30.    If chkPaint.Value = 1 Then
  31.       frmMain.g_wndForm.SetPaintCallback Me
  32.       frmMain.g_wndForm.Redraw rdw_ERASENOW + rdw_FRAME + rdw_INVALIDATE + rdw_UPDATENOW
  33.    Else
  34.       frmMain.g_wndForm.SetPaintCallback Nothing
  35.       frmMain.g_wndForm.Redraw rdw_ERASENOW + rdw_FRAME + rdw_INVALIDATE + rdw_UPDATENOW
  36.    End If
  37. End Sub
  38. Private Sub IsgPaintSink_ClientPaint(ByVal hdc As Long, ByVal left As Long, ByVal top As Long, ByVal right As Long, ByVal bottom As Long)
  39.    ' Do not paint on the client area
  40.    ' Let form do it's default painting
  41. End Sub
  42. Private Sub IsgPaintSink_FramePaint(ByVal hdc As Long)
  43. Debug.Print hdc
  44.    Dim HWND As Long
  45.    HWND = frmMain.HWND
  46.    ' Get window size
  47.    Dim rcSize As RECT
  48.    GetWindowRect HWND, rcSize
  49.    ' Get caption rectangle
  50.    Dim rcCaption As RECT
  51.    Dim nBorder%
  52.    nBorder = GetSystemMetrics(SM_CXFRAME)
  53.    rcCaption.left = nBorder - 1
  54.    rcCaption.top = nBorder - 1
  55.    rcCaption.right = rcSize.right - rcSize.left - nBorder + 1
  56.    rcCaption.bottom = rcCaption.top + GetSystemMetrics(SM_CYCAPTION) - 1
  57.    ' Create font
  58.    Dim hOldFont As Long
  59.    Dim font As New StdFont
  60.    font.Bold = True
  61.    font.name = "Arial"
  62.    font.Size = 12#
  63.    Dim f As IFont
  64.    Set f = font
  65.    ' Draw some extra text on the caption
  66.    hOldFont = SelectObject(hdc, f.hFont)
  67.    SetTextColor hdc, GetSysColor(COLOR_CAPTIONTEXT)
  68.    rcCaption.right = rcCaption.right - GetSystemMetrics(SM_CXSMICON) - 10
  69.    DrawText hdc, "Simple Frame Paint Example", -1, rcCaption, DT_SINGLELINE + DT_VCENTER + DT_RIGHT
  70.    SelectObject hdc, hOldFont
  71. End Sub
  72. Private Function IsgPaintSink_GetFlags() As sgWindow.PaintFlag
  73.    ' In this example we are painting over the standard caption bar.
  74.    IsgPaintSink_GetFlags = pfFramePaint + pfFrameAfterDefault
  75. End Function
  76.